1. Field of the Invention
The present invention relates in general to memory devices, and more particularly file systems suitable for use with nonvolatile memories.
2. The Background Art
As is known to those skilled in the art, numerous file system implementations have been developed. Most file systems known in the art have been developed with the assumption that the files would be stored on a magnetic disk orxe2x80x94in the case of data networking implementationsxe2x80x94on a magnetic disk attached to a network file server (xe2x80x9cNFSxe2x80x9d). Typically, files are divided into data blocks, and these blocks are laid out on the disk in which the files are to be stored. The layout of the blocks on the disk is typically optimized for minimizing the access time for file blocks stored on these disks. These file systems are normally very large, and hence very efficient file searching strategies have been developed.
Most file systems known in the art assume that a complex directory structure will be imposed on the files, and hence complex data structures have typically been required to handle them. However, other file systems known to those skilled in the art store files in a contiguous fashion. For example, on some types of nonvolatile memory, such as flash memory media, files are typically stored in a contiguous fashion on the flash card containing the flash memory. In such a flash memory medium, there is typically no concept of xe2x80x9cfile blocksxe2x80x9d involved. As known to those skilled in the art, however, flash media has its own peculiarities. For example, flash media typically must be reformatted to regain lost space.
Nonvolatile (sometimes written as xe2x80x9cnon-volatilexe2x80x9d) random access memory (xe2x80x9cnvram,xe2x80x9d or xe2x80x9cNVRAMxe2x80x9d) is typically a form of static RAM whose contents are saved when a computer is turned off or loses its external power source. As is known to those skilled in the art, nvram may be implemented in various ways, including by providing static RAM with backup battery power, or by saving its contents and restoring them from an Electrically Erasable Programmable Read Only Memory (xe2x80x9cEEPROMxe2x80x9d).
The development of nvram enabled files to be stored in a system in a persistent way. However, existing file systems are inadequate for addressing the unique set of challenges presented by the nvram memory storage media. First and foremost, the nvram media is relatively small in terms of memory capacity (typically ranging from a few hundred kilobytes to a few megabytes). Thus, only a relatively small number of files can be stored on the media. Secondly, nvram can be accessed relatively quickly, in comparison to magnetic disks, and hence disk block layout is not a major factor that affects the seek time parameter. Also, no directory structure is typically imposed on the nvram medium.
Moreover, because critical system data is often stored in nvram (e.g., cryptographic keys, system start-up configuration files, or other types of secure files), an nvram file system must be reliable. Specifically, a system xe2x80x9ccrashxe2x80x9d should not corrupt the file system. In order to deal with these problems, a simple but elegant file system storage for the nvram medium is disclosed herein. It provides all the necessary functionality without being burdened by unnecessary details and restrictions imposed by a traditional file system. The main assumptions of the file system design according to embodiments of the present invention are that (1) the file system structure is flat (i.e., does not contain directories), and (2) a relatively small amount of memory space is available. Also, an important design goal is not to have excessive file system information in the nvram memory medium at any given time. Most of the information is kept on the nvram, and based on this, other information may be obtained. Thus, a system crash will not result in loss of vital information which might have been buffered in memory. These and other features and advantages of the present invention will be presented in more detail in the following specification of the invention and in the associated figures.
A file system for nonvolatile memory media is disclosed, based on the assumptions that the file system structure is flat (i.e., does not contain directories), and that a relatively small amount of memory space is available. The nonvolatile memory medium is divided into logical blocks of predetermined size, depending on the typical file size expected for each particular implementation. Each of these logical blocks includes a header describing the contents of the block. For example, the block header may comprise a magic number indicating whether the block is a valid file system block or a free block, the name of the file to which the current block belongs, a flag indicating whether the current block is the first or last block of the file, the block number of the next block of the current file, if any, and the length of valid data in the present block.